<?php

namespace App\Http\Requests\Landscaping;

use Illuminate\Foundation\Http\FormRequest;
use App\Http\Requests\BaseRequest;
use Illuminate\Validation\Rule;

class LandscapingRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->route('id');
        return [
            'park_name' => 'required',
            'park_number' => 'required',
            // 'park_number' => ['required','integer',Rule::unique('landscapings')->ignore($id)->where(function ($query) {
            //         $query->where('deleted_at',null);
            //     })],
            // 'park_number' => "required|integer|unique:landscapings,park_number,$id,id,deleted_at,NULL",
            'park_address' => 'required',
            // 'clean_time' => 'required',
            // 'vegetation_id' => 'required|integer',
            // 'vegetation_sign' => 'required',
            // 'vegetation_yh_time' => 'required',
            // 'vegetation_yh_areas' => 'required',
            // 'vegetation_areas' => 'required',
            // 'task_load' => 'required',
            'principal_id' => 'required|integer',
            'phone' => 'required|regex:/^1[345789][0-9]{9}$/'
        ];
    }

    public function messages() 
    {
        return [
            'park_name.required' => '园林名称不能为空',
            'park_number.required' => '园林编号不能为空',
            'park_number.integer' => '园林编号只能填写数字',
            'park_number.unique' => '园林编号重复',
            'park_address.required' => '园林地址不能为空',
            'clean_time.required' => '清理时间不能为空',
            'vegetation_id.required' => '植被类型不能为空',
            'vegetation_id.integer' => '植被类型只能填写数字',
            'vegetation_sign.required' => '植被生长情况不能为空',
            'vegetation_yh_time.required' => '植被养护时间不能为空',
            'vegetation_yh_areas.required' => '养护面积不能为空',
            'vegetation_areas.required' => '系统推荐面积不能为空',
            'task_load.required' => '任务量不能为空',
            'principal_id.required' => '负责人不能为空',
            'principal_id.integer' => '负责人只能填写数字',
            'phone.required' => '手机号不能为空',
            'phone.regex' => '手机号不合法'
        ];
    }

}
